$(function () {
    ${entity?uncap_first}.init();
});

var ${entity?uncap_first} = {
    init: function(){
        // table数据加载
        ${entity?uncap_first}.table();
        // 按钮事件绑定
        common.btnEventBinding(true,{
            entityObject : ${entity?uncap_first}
            //other: [{"className":".fanta-btn-remove","method":"remove"}]
        });
    },
    table: function () {
        common.table({
            tableId : "#${entity?uncap_first}Table",
            url : "/${entity?uncap_first}/page${entity}Data",
            queryParamsCallBack : function (params) {
                return params;
            },
            columns : [{
                checkbox: true
            },
            <#list table.fields as field>
            {
                field: '${field.propertyName}',
                title: '${field.comment}',
                halign: 'center',
                align: 'center'
            }<#if field_has_next>,</#if>
            </#list>
            , {
                field: 'handle',
                title: '操作',
                width: '12',
                widthUnit: 'rem',
                halign: 'center',
                align: 'center',
                formatter: function (value, row, index) {
                    return "<button type='button' class='btn btn-warning btn-sm' onclick='${entity?uncap_first}.edit("+ row.${cfg.keyFieldHump} +")'><i class='fas fa-pen mr-2'></i><span>修改</span></button>";
                }
            }]
        });
    },
    reload: function () {
        $('#${entity?uncap_first}Table').bootstrapTable("refresh");
    },
    reset: function () {
        // $("#name").val('');
        ${entity?uncap_first}.reload();
    },
    add: function () {
        common.addTab({
            title: "新建${table.comment}",
            url: "/${entity?uncap_first}/form"
        });
    },
    edit: function (${cfg.keyFieldHump}) {
        common.addTab({
            title: "编辑${table.comment}",
            url: "/${entity?uncap_first}/form?${cfg.keyFieldHump}=" + ${cfg.keyFieldHump}
        });
    },
    getSelectedData: function () {
        return $('#${entity?uncap_first}Table').bootstrapTable('getSelections');
    },
    remove: function () {
         common.remove({
            entityObject : ${entity?uncap_first},
            url : "/${entity?uncap_first}/delete",
            keyId : "${cfg.keyFieldHump}"
        });
    }
};

function reload() {
    ${entity?uncap_first}.reload();
}
